<?php
/**
 * Created by PhpStorm.
 * User: zd
 * Date: 2018/10/15
 * Time: 10:38
 */

namespace app\api\service;

use \app\api\model\ThirdApp;
use think\Cache;
use think\Loader;

Loader::import('WorkWx.callback.WXBizMsgCrypt',EXTEND_PATH);
class WorkAccessToken extends \ServiceCorpAPI
{

    function __construct($suite_id = null, $suite_secret = null, $suite_ticket = null, $authCorpId = null, $permanentCode = null,$uid=null)
    {
        parent::__construct($suite_id, $suite_secret, $suite_ticket, $authCorpId, $permanentCode);
    }

    /**
     * 刷新通讯录的accesstoken
     * @param $suite_id
     * @param $suite_secret
     * @param $key
     * @param $permanent_code
     * @return \CorpAPI
     */
    public function getContactAccessToken($suite_id,$suite_secret,$key,$permanent_code){
                $vars =  Cache::get($suite_id);
                $vars = json_decode($vars);
                $suite_ticket = $vars->SuiteTicket;
                $service =  new \ServiceCorpAPI($suite_id,$suite_secret,$suite_ticket,$key,$permanent_code);
                $service->RefreshAccessToken();
            return $service;
    }
}